package marionito.servlets;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import marionito.domaine.Partie;
import marionito.usecases.GestionParties;

/**
 * Servlet implementation class Liste
 */
@WebServlet(name = "lister.html")
public class Liste extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@EJB
	private GestionParties gestionParties;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		List<Partie> listeParties = gestionParties.listerPartiesPasCommencee();
		getServletContext().setAttribute("lesParties", listeParties);
		getServletContext().getNamedDispatcher("rejoindrePartie.html").forward(
				request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
